<style>
    .engindao_bac{height: 680px;overflow-y: auto}
    #but_guanjia{margin: 10px 0 10px 10px}
    /*.layui-nav-tree .layui-this{background: #f0f6ff!important;}*/
    #wenlist{padding: 10px 0 0 0}
    #wenlist .hh{line-height: 35px;position: relative;cursor: pointer;padding: 0 10px}
    #wenlist .hh .ww{width:calc(100% - 35px);overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
    #wenlist .hh:hover{background-color: #f0f6ff;}
    #wenlist .hhthis{background-color: #f0f6ff;}
    #wenlist .hh .wentou{right: 0;top: 0;position: absolute;width: 20px;cursor: pointer;}
    #wenlist .hh .typebao{padding-left: 30px}
    #wenlist .hh .typeban i{color: #0E0EFF;font-weight: bold;font-size: 18px;}
    #wenlist .hh .typebao i{color: #0E0EFF;font-weight: bold;font-size: 18px;}
</style>
<div class="layui-col-md3" id="engindao">
    <div class="engindao_bac">
        <div class="layui-table-tool-temp">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm laytp-container-tool-button" id="but_guanjia" onclick="auth_but_func_guanjia('管理文件夹')" style="padding-right: 12px;">文件夹权限管理</button>
            </div>
        </div>
        <div class="engindao_div" style="background-color: #f5f5f5;width: calc(100% - 20px);margin-left: 10px;border-radius: 5px">
            <div class="engindao_title"><b>文件导航</b></div>
            <div style="clear: both"></div>
            <div id="wenlist">

            </div>
            <div class="lan_wen" style="text-align: center"><img src="/static/admin/images/nolan2.png" style="margin-top: 20px"></div>
        </div>
    </div>
</div>
<script>

    function setWenTou(obj, zhanid) {
        if(!obj){
            obj = $(".hh[data-id="+zhanid+"]");
        }
        $(".hh").removeClass('hhthis');
        $(obj).addClass('hhthis');

        zhanid = $(obj).attr('data-id');
        var datatype = $(".hh[data-id="+zhanid+"]").attr('data-type');
        if(PUB_WENLIST[datatype+zhanid]){
            setYulanMuban(PUB_WENLIST[datatype+zhanid]);
        }
    }

    function setWenIconTou(obj) {
        var thisId = $(obj).parents('.hh').attr('data-id');
        var key = $(obj).attr('key');
        if(key == 'right'){
            $(obj).addClass('layui-icon-down').removeClass('layui-icon-right').attr('key','down').attr('title','收起');
            $(".hh[data-pid="+thisId+"]").addClass('layui-hide');
        }else{
            $(obj).addClass('layui-icon-right').removeClass('layui-icon-down').attr('key','right').attr('title','展开');
            $(".hh[data-pid="+thisId+"]").removeClass('layui-hide');
        }

        stopPropagation(obj)
    }



    var PUB_WENLIST;
    function setWenList(muid=0, zhanid=0){


        PUB_WENLIST = [];
        facade.ajax({url: ask_engin_mu_wen, data: {muid:muid,enginid:param_enginid}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                $("#wenlist").html('');
                if(data.length > 0){
                    $(".lan_wen").addClass('layui-hide');
                }else{
                    $(".lan_wen").removeClass('layui-hide');
                }

                var str = '';
                for (var key in data){
                    PUB_WENLIST[data[key].type+data[key].id] = data[key];

                    if(!zhanid && key == 0){
                        zhanid = data[key].id
                    }
                    var children = data[key].children || [];

                    str += '<div class="hh" data-id="'+data[key].id+'" data-pid="'+data[key].pid+'" data-type="'+data[key].type+'" onclick="setWenTou(this)">';
                    if(data[key].type == 'bao'){
                        str += '<div class="ww typeban"><i class="layui-icon layui-icon-list"></i>'+data[key].title+'</div>';
                    }else{
                        str += '<div class="ww">'+data[key].title+'</div>';
                    }
                    if(children.length > 0){
                        str += '<i class="layui-icon layui-icon-right wentou" key="right" onclick="setWenIconTou(this)" title="收起"></i>';
                    }
                    str += '</div>';

                    for (var mmm in children){
                        PUB_WENLIST[children[mmm].type+children[mmm].id] = children[mmm];
                        str += '<div class="hh" data-id="'+children[mmm].id+'" data-pid="'+children[mmm].pid+'" data-type="'+children[mmm].type+'" onclick="setWenTou(this)">';
                        if(children[mmm].type == 'bao'){
                            str += '<div class="ww typebao"><i class="layui-icon layui-icon-list"></i>'+children[mmm].title+'</div>';
                        }else{
                            str += '<div class="ww">'+children[mmm].title+'</div>';
                        }
                        str += '</div>';
                    }
                }
                $("#wenlist").html(str);


                if(data.length > 0){
                    setWenTou('', zhanid);
                }
            }
        });
    }



    function stopPropagation(e){
        if(e && e.stopPropagation){
            e.stopPropagation()
        }else{
            window.event.cancelBubble = true;
        }
    }



    function auth_but_func_guanjia() {
        openPageEdit('guanmu.php?close=1&enginid='+param_enginid);
    }
</script>
